\begin{algorithm}
\caption{Query($r$,$v$)}
\label{alg:query}
\begin{algorithmic}[1]
\IF{$r$ is not a leaf}
    \STATE $w \leftarrow BinarySearch(r.I_{mid},v.X)$ \\
        \ \ \ \ $w.X$ is the closest one such that $w.X \leq v.X$ \\
    \IF{$v.P \subseteq w.P$} 
            \STATE $Reachable \leftarrow TRUE$; 
        \ENDIF
    \IF{$v.P[2]<r.x_{mid}$}
        \STATE Query($r.left$);  
    \ELSE 
    \IF{$v.P[1]>r.x_{mid}$}
        \STATE Query($r.right$); 
    \ENDIF
    \ENDIF  
\ENDIF 
\end{algorithmic}
\end{algorithm}